<template>
  <div>
    <div class="content">
      <el-form :label-position="'right'" :model="formData" :rules="rules" ref="formData" label-width="100px" class="demo-ruleForm">
        <el-form-item label="企业号" prop="id">
          <el-input v-model="formData.id"></el-input>
        </el-form-item>
        <el-form-item label="企业名称">
          <el-input v-model="formData.name"></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input v-model="formData.password"></el-input>
        </el-form-item>
        <el-form-item label="企业联系人">
          <el-input v-model="formData.contact"></el-input>
        </el-form-item>
        <el-form-item label="手机号码">
          <el-input v-model="formData.telephone"></el-input>
        </el-form-item>
        <el-form-item label="公司电话">
          <el-input v-model="formData.phone"></el-input>
        </el-form-item>
        <el-form-item label="电子邮件">
          <el-input v-model="formData.email"></el-input>
        </el-form-item>
        <el-form-item label="通讯地址">
          <el-input v-model="formData.address"></el-input>
        </el-form-item>
        <el-form-item label="企业官网">
          <el-input v-model="formData.website"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit('formData')">保存</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
export default {
  name: 'addenterprise',
  data () {
    return {
      formData: {
        id: '',
        name: '',
        password: '',
        contact: '',
        telephone: '',
        phone: '',
        email: '',
        address: '',
        website: ''
      },
      rules: {
        id: [
          { required: true, message: '请输入活动名称', trigger: 'blur' }
        ]
      },
      resData: {}
    }
  },
  methods: {
    onSubmit (formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$http.post('/company/save', this.formData).then((res) => {
            this.resData = res.data
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    }
  }
}
</script>
<style lang="stylus" scoped>
.content {
  margin: 20px;
  padding: 20px;
  border: 1px solid #e7ecf1;

  .title {
    height: 48px;
    line-height: 48px;
    margin-bottom: 10px;
    border-bottom: 1px solid #eef1f5;
  }
}
</style>
